//
//  GameLeftTableViewCell.m
//  Vlink
//
//  Created by LJH on 2017/9/5.
//  Copyright © 2017年 myTV. All rights reserved.
//

#import "GameLeftTableViewCell.h"

@interface GameLeftTableViewCell()
@property (nonatomic, strong) UIView *redView;
@property (nonatomic, strong) UIView *topView;
@property (nonatomic, strong) UIView *bottomView;
@property (nonatomic, strong) UIView *rightView;

@end
@implementation GameLeftTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.topView = [[UIView alloc] init];
        self.topView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.topView];
        [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.equalTo(self.contentView);
            make.right.equalTo(self.contentView).offset(-1);
            make.height.mas_equalTo(1);
        }];
        
        self.bottomView = [[UIView alloc] init];
        self.bottomView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.bottomView];
        [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.equalTo(self.contentView);
            make.right.equalTo(self.contentView).offset(-1);
            make.height.mas_equalTo(1);
        }];
        
        self.rightView = [[UIView alloc] init];
        self.rightView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.rightView];
        [self.rightView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.right.equalTo(self.contentView);
            make.width.mas_equalTo(1);
        }];
        
        
        self.name = [[UILabel alloc] initWithFrame:CGRectZero];
        self.name.numberOfLines = 0;
        self.name.font = [UIFont systemFontOfSize:13];
        self.name.textColor = kColor888888;
        self.name.highlightedTextColor = kColor333333;
        [self.contentView addSubview:self.name];
        [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(10);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.right.equalTo(self.contentView);
        }];
        
        self.redView = [[UIView alloc] init];
        self.redView.backgroundColor = kThemeColor;
        [self.contentView addSubview:self.redView];
        [self.redView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(4);
            make.height.mas_equalTo(25);
            make.left.centerY.equalTo(self.contentView);
        }];

    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    self.topView.backgroundColor = selected ? kLineColor : [UIColor whiteColor];
    self.bottomView.backgroundColor = selected ? kLineColor : [UIColor whiteColor];
    self.rightView.backgroundColor = selected ? [UIColor whiteColor] : kLineColor;
    self.highlighted = selected;
    self.name.highlighted = selected;
    self.name.font = selected ? [UIFont systemFontOfSize:15] : [UIFont systemFontOfSize:13];
    self.redView.hidden = !selected;
}

- (void)setIndexPath:(NSIndexPath *)indexPath
{
    self.topView.hidden = (indexPath.row == 0);
}

@end
